<template>
    <div class="return-money-detailed-wrapper">
        <p v-if="veriablePeriodIntro" class="veriableperiod-intro">{{veriablePeriodIntro}}</p>
        <div class="return-money-detailed-list">
            <div class="detailed-info">
                <i></i>
                <div class="top-font">
                    起息日期
                </div>
                <div class="info-font">
                    {{bidDetail.dateOfValue}}
                </div>
            </div>

            <div class="detailed-info" v-for="(item, index) in bidDetail.repaymentPlan" :key="index"
                 :class="{'WH':item.status === 'WH', 'detailed-info-last': index === bidDetail.repaymentPlan.length - 1}">
                <i></i>
                <div class="top-font">
                    <p>第<span>{{item.instalment}}</span>期 <span class="ml">{{item.repaymentTime}}</span></p>
                </div>
                <div class="info-font">
                    本金 <span>{{formatMoney(item.principal)}}</span>元
                </div>
                <div class="info-font">
                    收益 <span>{{formatMoney(item.earnings)}}</span>元
                </div>
            </div>
        </div>

    </div>
</template>
<script>
  import formatMoney from '~/helper/formatMoney'
  export default {
    name: 'repayment-plan',
    props: {
      bidDetail: {
        type: Object,
        default: () => {}
      }
    },
    methods: {
      formatMoney (money) {
        return formatMoney.formatMoney(money)
      }
    },
    computed: {
      veriablePeriodIntro () {
        var bidDetail = this.bidDetail
        if ((bidDetail.prepaymentStartDate || bidDetail.prepaymentPlanDate) && (bidDetail.bidStatus === 'HKZ' || bidDetail.bidStatus === 'YJQ')) {
          if (bidDetail.prepaymentStartDate || !bidDetail.prepaymentPlanDate) {
            return bidDetail.prepaymentStartDate + '后，允许融资者提前还款，届时会出现提前还款'
          } else {
            return bidDetail.prepaymentPlanDate + '，融资者申请提前还款，回款明细已更新'
          }
        }
      }
    }
  }
</script>
<style lang="sass" src="~/assets/sass/biddetail.sass"></style>